home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0045_VGA ClrScr #1.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  63 lines

  1.  {
  2.  Anivga is the best set of Graphics routines i've seen For the PC since
  3.  i stopped using my old 4,7 Mhz MSX (which had smooth sprites &
  4.  scrolling) and the one With the most extra's.
  5.  
  6. Well, here is >ONE< solution For you.  It is one I have used in a
  7. streetfighter Type game a friend and I have been working on (the friend
  8. is an artist who has been doing the pics While I'm doing the software).
  9. It turns out, using an index-to-index copy during vertical retrace is
  10. fast enough to get at least (and I mean at LEAST--I've been able to over
  11. Double this rate) 18.2 frames per second on a 16bit VGA card.
  12.  
  13. The code (in pascal, although the Program itself is written in C++, the
  14. theory works With TP6.0) would look something like this:
  15. }
  16.  
  17. Type
  18.   ScreenRec = Array[0..63999] of Byte;
  19.   ScreenPtr = ^ScreenRec;
  20.  
  21. Var
  22.   VGAScreen : ScreenRec Absolute $A000:$0000; {I think thats how you do
  23.                                                it, been a While since I
  24.                                                had to do things this way}
  25.  
  26. Procedure VS_PutPixel(x, y: Integer; c:Byte; VS: ScreenPtr);
  27.  
  28. begin
  29.   VS^[(y*320)+x] := c; {Again, this may be off slightly--my original
  30.                         pascal Implementation used a member Variable in
  31.                         an Object}
  32. end;
  33.  
  34. Procedure VS_Write(VS: ScreenPtr);
  35.  
  36. Var
  37.   X : Integer;
  38.   Y : Integer;
  39.  
  40. begin
  41.   {Wait For a retrace--see a VGA manual For how to do this, it takes
  42.   monitoring two ports.  if you are already in a retrace, wait For it to
  43.   end and another one to begin}
  44.   For Y := 0 to 199 do
  45.     For X := 0 to 319 do
  46.       VGAScreen[(Y*320)+X] := VS^[(Y*320)+X];
  47. end;
  48.  
  49. {
  50. With this method, you even have time in the nexted For loops (!) to do a
  51. Comparison.  One I typically use (For emulating multiple planes) is if
  52. VS^[(Y*320)+X] <> 0...  That lets me copy multiple screens.  to give you
  53. an idea of how fast this is, on my 386/25, I can do this during a timer
  54. interrupt (18.2 times a second) without any problems, and still have
  55. time to do full collision detection and multisprite animation with
  56. scrolling backgrounds and Soundblaster Sound.  During the retrace
  57. period, you can move quite a bit of inFormation into the VGA card,
  58. because memory accesses are MUCH faster (the screen is also not being
  59. updated).  This is CompLETELY flicker free using this technique (if
  60. smaller sections are chaging, you MIGHT consider only copying parts of
  61. the screen).
  62.  
  63. }